/*
 * @name: 
 * @Author: 刘大可
 * @Date: 2023-05-11 14:46:49
 * @LastEditors: 刘大可
 * @LastEditTime: 2023-10-11 10:51:46
 */

module.exports = {
    data() {
        return {
            pub_query:null,
            union_coupon_list: [],

        }
    },
    onInit(opt) {
        // console.log(opt);
    },
    onLoad(opt) {
        if (opt.scene) {
            this.pub_query={}
            let query = decodeURIComponent(opt.scene).split('=')
            console.log(query);

            for (let i = 0; i < query.length; i++) {
                const element = query[i];
                if (i%2==0) {
                    this.pub_query[element]=query[i+1]
                }
            }
            if (this.pub_query.s_id) {
            // if (query[1]) {
                uni.setStorageSync('schoolId', this.pub_query.s_id)
            }

        }
       
    },
    onShow(){

       
        let isNeedCoupon = {
            "gc_school/pages/public/index": true,
            "gc_school/pages/foold/foold": true
        }
        if (isNeedCoupon[this.__route__]) {
            this.getUnionCouponList()
            if (uni.getStorageSync('token')) {
                
            }
        }

        
        console.log(".........................");
        console.log(isNeedCoupon[this.__route__]);
    },
    methods:{

       async  getUnionCouponList() {
            await this.login().then((res) => {
                console.log("您已登陆！");
            })

            var app = getApp();
            var self = this;
            app.globalData.util.request({
                url: 'UserCoupon/couponindex',
                data: {
                    s_id: uni.getStorageSync('schoolId'),
                },
                success(res) {
                    console.log("可领取", res.data.data)
                    self.setData({
                        union_coupon_list: res.data.data
                    });
                }
            },true);
        },
       
    }
}
